<?php $layout = 'app';
$title = 'MyCMS - 首页'; ?>

<div style="text-align: center; padding: 2rem 0;">
    <h1 style="color: #007bff; margin-bottom: 1rem;">MyCMS Skeleton</h1>
    <p style="font-size: 1.1rem; color: #666; margin-bottom: 2rem;">轻量 MVC + 路由骨架</p>

    <div style="background: white; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 2rem;">
        <h2 style="color: #28a745; margin-bottom: 1rem;">✅ 项目骨架已创建成功</h2>
        <p style="margin-bottom: 1rem;">你可以开始开发功能模块。</p>

        <div style="text-align: left; max-width: 600px; margin: 0 auto;">
            <h3 style="margin: 1.5rem 0 1rem; color: #333;">核心组件：</h3>
            <ul style="list-style: none; padding: 0;">
                <li style="margin: 0.5rem 0; padding: 0.5rem; background: #f8f9fa; border-radius: 4px;">
                    <strong>入口：</strong> public/index.php
                </li>
                <li style="margin: 0.5rem 0; padding: 0.5rem; background: #f8f9fa; border-radius: 4px;">
                    <strong>路由：</strong> routes/web.php（已注册 / → HomeController@index）
                </li>
                <li style="margin: 0.5rem 0; padding: 0.5rem; background: #f8f9fa; border-radius: 4px;">
                    <strong>控制器：</strong> app/Controllers/HomeController.php
                </li>
                <li style="margin: 0.5rem 0; padding: 0.5rem; background: #f8f9fa; border-radius: 4px;">
                    <strong>视图：</strong> templates/home.php
                </li>
            </ul>
        </div>
    </div>

    <div style="display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap;">
        <a href="/posts" class="btn">查看文章</a>
        <?php
        $currentUser = null;
        try {
            $currentUser = App\Services\Auth::user();
        } catch (Exception $e) {
            // 忽略错误
        }
        if ($currentUser): ?>
            <a href="/posts/create" class="btn">写文章</a>
        <?php else: ?>
            <a href="/register" class="btn btn-secondary">立即注册</a>
        <?php endif; ?>
    </div>

    <div style="margin-top: 2rem; padding: 1rem; background: #e9ecef; border-radius: 4px; font-size: 0.9rem; color: #666;">
        <p><strong>功能特性：</strong></p>
        <p>✅ MVC 架构 | ✅ 路由系统 | ✅ 用户认证 | ✅ CSRF 防护 | ✅ 登录限速 | ✅ 访问日志 | ✅ 错误处理</p>
    </div>